package com.five.wisdomEat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.five.wisdomEat.entity.StudentInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper extends BaseMapper<StudentInfo> {
    //查询所有学生信息
    @Select("SELECT * FROM studentinfo")
    List<StudentInfo> selectStudentList();

    //添加学生
    @Insert("INSERT INTO studentinfo " +
            "(id,s_number,s_name,s_gender,s_phone,s_hometown,s_nationality,s_political_face," +
            "email,birth_date,home_address,academy,major,class,id_card_number,face_photo) " +
            "VALUES (null,#{sNumber},#{sName},#{sGender},#{sPhone},#{sHometown},#{sNationality},#{sPoliticalFace}" +
            ",#{email},#{birthDate},#{homeAddress},#{academy},#{major},#{classes},#{idCardNumber},null)")
    Integer insertStudent(StudentInfo studentInfo);

    //根据学生编号修改学生
    @Update("UPDATE studentinfo SET " +
            "s_name=#{sName},s_gender=#{sGender},s_phone=#{sPhone},s_hometown=#{sHometown}" +
            ",s_nationality=#{sNationality},s_political_face=#{sPoliticalFace}" +
            ",email=#{email},birth_date=#{birthDate},home_address=#{homeAddress}," +
            "academy=#{academy},major=#{major},class=#{classes},id_card_number=#{idCardNumber} " +
            "WHERE s_number = #{sNumber}")
    Integer updateStudent(StudentInfo studentInfo);

    //根据学生编号删除学生
    @Delete("DELETE FROM studentinfo WHERE s_number = #{sNumber}")
    Integer deleteStudent(String sNumber);
}
